//
//  RBSystemDetailGuessCell.m
//  zhongzhenglu
//
//  Created by XL on 2022/7/14.
//

#import "RBSystemDetailGuessCell.h"
#import "RanTool.h"
#import <UIColor+YYAdd.h>
#import "UIView+RBAdd.h"
#import "RBDefine.h"
#import "UIImageView+RBAdd.h"
#import "RBCartResponse.h"
#import "RBNoticeDetailResponse.h"
#import "RBBrandGoodsListResponse.h"
#import "RBShopDetailGoodsResponse.h"

@interface RBSystemDetailGuessCell()

@property(nonatomic, strong)IBOutlet UIImageView *imgView;
@property(nonatomic, strong)IBOutlet UILabel *nameL;
@property(nonatomic, strong)IBOutlet UILabel *desL;
@property(nonatomic, strong)IBOutlet UILabel *priceL;
@property (weak, nonatomic) IBOutlet UILabel *originPriceL;

@end

@implementation RBSystemDetailGuessCell

- (void)awakeFromNib
{
    [super awakeFromNib];
    
    [self zoomSubViewsWithSelf];
}

- (void)setCellModel:(RBCellModel *)cellModel
{
    if([cellModel.cellData isKindOfClass:RBCartLikeModel.class])
    {
        RBCartLikeModel *model = cellModel.cellData;
        [self.imgView setImageWithUrl:model.picurl placeHolder:nil];
        self.nameL.text = model.good_name;
        self.desL.text = nil;
        
        NSString *priceString = [NSString stringWithFormat:@"¥%@", model.sell_price];
        
        self.priceL.attributedText = [NSString changeSectionFontWithString:priceString font:[UIFont systemFontOfSize:Zoom(16)] from:1 lenth:(priceString.length - 1)];
        
        self.originPriceL.hidden = NO;
        self.originPriceL.attributedText = [NSString stringMidLine:[NSString stringWithFormat:@"¥%@", model.shop_price]];
        
//        self.priceL.attributedText = [RanTool attributeStringMaker:^(NSMutableArray *maker) {
//            [maker addAttributeStringWithFont:[UIFont systemFontOfSize:Zoom(10)] color:[UIColor colorWithHexString:@"#F25B50"] string:@"￥"];
//            [maker addAttributeStringWithFont:[UIFont systemFontOfSize:Zoom(16)] color:[UIColor colorWithHexString:@"#F25B50"] string:model.sell_price];
//            [maker addAttributeStringWithFont:[UIFont systemFontOfSize:Zoom(16)] color:UIColor.clearColor string:@" "];
//            [maker addAttributeStringWithFont:[UIFont systemFontOfSize:Zoom(12)] color:[UIColor colorWithHexString:@"#AEAEAE"] string:[NSString stringWithFormat:@"￥%@",model.shop_price] lineSpacing:0 througnLineHeight:1 throughLineColor:[UIColor colorWithHexString:@"#AEAEAE"]];
//        }];
    }
    else if([cellModel.cellData isKindOfClass:RBNoticeDetailGoodsModel.class])
    {
        RBNoticeDetailGoodsModel *model = cellModel.cellData;
        [self.imgView setImageWithUrl:model.picurl placeHolder:nil];
        self.nameL.text = model.good_name;
        self.desL.text = nil;
        
        NSString *priceString = [NSString stringWithFormat:@"¥%@", model.sell_price];
        
        self.priceL.attributedText = [NSString changeSectionFontWithString:priceString font:[UIFont systemFontOfSize:Zoom(16)] from:1 lenth:(priceString.length - 1)];
        self.originPriceL.hidden = NO;
        self.originPriceL.attributedText = [NSString stringMidLine:[NSString stringWithFormat:@"¥%@", model.shop_price]];
//        self.priceL.attributedText = [RanTool attributeStringMaker:^(NSMutableArray *maker) {
//            [maker addAttributeStringWithFont:[UIFont systemFontOfSize:Zoom(10)] color:[UIColor colorWithHexString:@"#F25B50"] string:@"￥"];
//            [maker addAttributeStringWithFont:[UIFont systemFontOfSize:Zoom(16)] color:[UIColor colorWithHexString:@"#F25B50"] string:model.sell_price];
//            [maker addAttributeStringWithFont:[UIFont systemFontOfSize:Zoom(16)] color:UIColor.clearColor string:@" "];
//            [maker addAttributeStringWithFont:[UIFont systemFontOfSize:Zoom(12)] color:[UIColor colorWithHexString:@"#AEAEAE"] string:[NSString stringWithFormat:@"￥%@",model.shop_price] lineSpacing:0 througnLineHeight:1 throughLineColor:[UIColor colorWithHexString:@"#AEAEAE"]];
//        }];
    }
    else if([cellModel.cellData isKindOfClass:RBBrandGoodsListModel.class])
    {
        RBBrandGoodsListModel *model = cellModel.cellData;
        [self.imgView setImageWithUrl:model.picurl placeHolder:nil];
        self.nameL.text = model.good_name;
        self.desL.text = nil;
        
        NSString *priceString = [NSString stringWithFormat:@"¥%@", model.sell_price];
        
        self.priceL.attributedText = [NSString changeSectionFontWithString:priceString font:[UIFont systemFontOfSize:Zoom(16)] from:1 lenth:(priceString.length - 1)];
        
        self.originPriceL.hidden = YES;
        
//        self.priceL.attributedText = [RanTool attributeStringMaker:^(NSMutableArray *maker) {
//            [maker addAttributeStringWithFont:[UIFont systemFontOfSize:Zoom(10)] color:[UIColor colorWithHexString:@"#F25B50"] string:@"￥"];
//            [maker addAttributeStringWithFont:[UIFont systemFontOfSize:Zoom(16)] color:[UIColor colorWithHexString:@"#F25B50"] string:model.sell_price];
//            [maker addAttributeStringWithFont:[UIFont systemFontOfSize:Zoom(16)] color:UIColor.clearColor string:@" "];
////            [maker addAttributeStringWithFont:[UIFont systemFontOfSize:Zoom(12)] color:[UIColor colorWithHexString:@"#AEAEAE"] string:[NSString stringWithFormat:@"￥%@",model.shop_price] lineSpacing:0 througnLineHeight:1 throughLineColor:[UIColor colorWithHexString:@"#AEAEAE"]];
//        }];
    }
    else if([cellModel.cellData isKindOfClass:RBShopDetailGoodsModel.class])
    {
        RBShopDetailGoodsModel *model = cellModel.cellData;
        [self.imgView setImageWithUrl:model.picurl placeHolder:nil];
        self.nameL.text = model.good_name;
        self.desL.text = nil;
        
        NSString *priceString = [NSString stringWithFormat:@"¥%@", model.sell_price];
        
        self.priceL.attributedText = [NSString changeSectionFontWithString:priceString font:[UIFont systemFontOfSize:Zoom(16)] from:1 lenth:(priceString.length - 1)];
        
        self.originPriceL.hidden = NO;
        self.originPriceL.attributedText = [NSString stringMidLine:[NSString stringWithFormat:@"¥%@", model.shop_price]];
        
//        self.priceL.attributedText = [RanTool attributeStringMaker:^(NSMutableArray *maker) {
//            [maker addAttributeStringWithFont:[UIFont systemFontOfSize:Zoom(10)] color:[UIColor colorWithHexString:@"#F25B50"] string:@"￥"];
//            [maker addAttributeStringWithFont:[UIFont systemFontOfSize:Zoom(16)] color:[UIColor colorWithHexString:@"#F25B50"] string:model.sell_price];
//            [maker addAttributeStringWithFont:[UIFont systemFontOfSize:Zoom(16)] color:UIColor.clearColor string:@" "];
//            [maker addAttributeStringWithFont:[UIFont systemFontOfSize:Zoom(12)] color:[UIColor colorWithHexString:@"#AEAEAE"] string:[NSString stringWithFormat:@"￥%@",model.shop_price] lineSpacing:0 througnLineHeight:1 throughLineColor:[UIColor colorWithHexString:@"#AEAEAE"]];
//        }];
    }
}

@end
